package com.neu.ui;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.neu.po.Dept;
import com.neu.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping(value="")
public class DeptController {
	@Autowired
	private DeptService service;
	@GetMapping("/index")
	public String selectAll(HttpSession session,Model m){
		List<Dept> dept=service.selectAll();
		m.addAttribute("dept",dept);
		return "index";
	}
	@PostMapping("/index")
	public String selectByName(String deptname,HttpSession session,Model m){
		List<Dept> dept=service.selectByName(deptname);
		m.addAttribute("dept",dept);
		return "index";
	}
}
